package com.hzsai.mininote.converter;

import com.hzsai.mininote.entity.NoteTypeEnum;

import javax.persistence.AttributeConverter;

/**
 * @author hzsai
 * @date 2020/1/8 20:24
 * @usage:
 */
public class NoteTypeEnumConverter implements AttributeConverter<NoteTypeEnum, Integer> {
    @Override
    public Integer convertToDatabaseColumn(NoteTypeEnum noteTypeEnum) {

        return noteTypeEnum.getId();
    }

    @Override
    public NoteTypeEnum convertToEntityAttribute(Integer integer) {
        return NoteTypeEnum.getFromId(integer);
    }
}
